package com.label.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.label.entity.Patientlabels;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Jianhua
 * @since 2022-03-27
 */
@Repository
public interface PatientlabelsMapper extends BaseMapper<Patientlabels> {
    @Select("select * from patientlabels")
    @Results( {
            @Result(id = true, property = "patientid", column = "patientid"),
//            @Result(property = "patientname", column = "patientname"),
//            @Result(property = "IDCard", column = "IDCard"),
//            @Result(property = "cartevital", column = "cartevital"),
//            @Result(property = "age", column = "age"),
//            @Result(property = "sex", column = "sex"),
            @Result(property = "labelbinds",column = "patientid",
            many = @Many(select = "com.label.mapper.LabelbindMapper.findlabelsByUserId"))
    })
    List<Patientlabels> findAlllabels();
    @Select("SELECT * FROM `patientlabels` WHERE patientid = #{id}")
    @Result(property = "labelbinds", column = "patientid",
                    many = @Many(select = "com.label.mapper.LabelbindMapper.findlabelsByUserId"))

    // 对userId进行赋值
    @Result(property = "id", column = "id")
    Patientlabels find(Integer id);
    @Select("select * from patientlabels where patientname like concat('%',#{key},'%')")
    @Results( {
            @Result(id = true, property = "patientid", column = "patientid"),
            @Result(property = "labelbinds",column = "patientid",
                    many = @Many(select = "com.label.mapper.LabelbindMapper.findlabelsByUserId"))
    })
    List<Patientlabels> selectlike(String key);

}
